package org.yang.keywords.enums;

/**
 * @Description: 枚举类及其方法
 * @Author: YangTing
 * @Date: 2024-07-03 20:25
 */

public class SeasonTest {
    public static void main(String[] args) {
        //toString()
        System.out.println(Season.SPRING);
        //name()
        System.out.println(Season.SPRING.name());
        //values()
        Season[] values = Season.values();
        for (Season season : values) {
            System.out.println(season);
        }
        //valueOf()
        System.out.println(Season.valueOf("AUTUMN"));
        //ordinal()
        System.out.println(Season.AUTUMN.ordinal());
        //调用枚举重写的方法
        Season.AUTUMN.show();
    }
}

interface Info{
    void show();
}

enum Season implements Info{
    SPRING("春天","春暖花开"),
    SUMMER("夏天","夏日炎炎"),
    AUTUMN("秋天","秋高气爽"),
    WINTER("冬天","冬日可爱");
    private final String seasonName;
    private final String seasonDesc;
    Season(String seasonName, String seasonDesc) {
        this.seasonName = seasonName;
        this.seasonDesc = seasonDesc;
    }
    public String getSeasonName() {
        return seasonName;
    }
    public String getSeasonDesc() {
        return seasonDesc;
    }
    @Override
    public void show() {
        System.out.println("Season.show");
    }
}